using System;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.UI;

namespace ASPNETVN.PORTAL.Modules.DOCUMENT.Controls
{
    public partial class ItemManager : AddEditItemControl
    {
        protected string GetExpiredDate(object date)
        {
            DateTime d = Convert.ToDateTime(date);
            String result = d.ToShortDateString(); 
            if (d.Year == 2049)
            {
                result = Global.RM.GetString("DATE_UNLIMITED");
            }
            return result;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PORTAL.Components.Share.Category.BuildDropDownListControl(ref cbCategory, this.ModuleID);
            }
        }

        protected void gvItems_PageIndexChanged(object sender, EventArgs e)
        {
            gvItems.SelectedIndex = -1;
        }
        
        protected void gvItems_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                Response.Redirect(HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, Convert.ToInt32(e.CommandArgument), "AddEditItem"));
            }
        }
    }
}